package grpc

import (
	"flag"
	"google.golang.org/grpc"
	"log"
	"net"
)

func Grpc(call func(server *grpc.Server)) {
	data := "127.0.0.1:8080"
	flag.Parse()
	lis, err := net.Listen("tcp", data)
	if err != nil {
		log.Fatalf("failed to listen: %v", err)
	}
	s := grpc.NewServer()
	call(s)
	log.Printf("server listening at %v", lis.Addr())
	if err := s.Serve(lis); err != nil {
		log.Fatalf("failed to serve: %v", err)
	}
}
